<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>资产管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#addRfid").click(function(){
				//验证是否是资源中心账户
				var warningRoleId = $("#warningRoleId").val();
				if(warningRoleId=='' || warningRoleId==null){
					$.jBox.alert('保存失败,没有找到关联的规则信息!', '提示!');
					return;
				}else{
					//验证是否有勾选
					var selectIds = $('input:checkbox[name=rowcheckbox]:checked');
					var assetIds = "";
					if(selectIds!=null&&selectIds!=''&&selectIds.length>0){
						for(var i =0;i<selectIds.length;i++){
							if(i<selectIds.length-1){
								assetIds = assetIds + selectIds[i].value+",";								
							}else{
								assetIds = assetIds + selectIds[i].value+"";
							}
						}
						$.ajax({
				            type:"POST",
				            url:'${ctx}/guobo/warnroleRfid/saveWarningRoleRfids',
				            data:{warningRoleId:warningRoleId,assetIds:assetIds},
				            //返回数据的格式
				            datatype: "json",
				            success:function(data){
				            	$.jBox.alert('保存成功!', '提示!');
				            	window.opener.location.href=window.opener.location.href;
				            	window.close();
				            },
				            //调用出错执行的函数
				            error: function(){
				            	$.jBox.alert('保存失败!', '提示!');
				            }         
				         });
					}else{
						$.jBox.alert('未勾选资产信息,请重新选择!', '提示!');
						return;
					}
					
				}
				
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function selectAll(checkObj,checkBoxName){
			var allChecks = $("input[name='rowcheckbox']");
			if(checkObj.checked){
				for(var i = 0;i<allChecks.length;i++){
					allChecks[i].checked = true;
				}
			}else{
				for(var i = 0;i<allChecks.length;i++){
					allChecks[i].checked = false;
				}
			}
		}
		
	</script>
</head>
<body>
	<form:form id="searchForm" modelAttribute="asset" action="${ctx}/guobo/asset/findRfidsNotInRole" method="post" class="breadcrumb form-search">
		<input id="warningRoleId" name="warningRoleId" type="hidden" value="${warningRoleId}"/>
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>物品名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>RFID：</label>
				<form:input path="rfid" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input id="addRfid" class="btn btn-primary" type="button" value="确定"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>
					<input type="checkbox" name="checkbox" id="checkbox" value="checkbox" onclick="javascript:selectAll(this,'rowcheckbox');"/>
				</th>
				<th>编码</th>
				<th>名称</th>
				<th>规格</th>
				<th>类型</th>
				<th>特征</th>
				<th>rfid编码</th>
				<th>展馆</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="asset">
			<tr>
				<td>
					<input type="checkbox" name="rowcheckbox" value="${asset.rfid }"/>
				</td>
				<td>
					${asset.code}
				</td>
				<td>
					${asset.name}
				</td>
				<td>
					${asset.spec}
				</td>
				<td>
					${asset.type}
				</td>
				<td>
					${asset.feature}
				</td>
				<td>
					${asset.rfid}
				</td>
				<td>
					${asset.exhHall.name}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>